package beautiful.butterfly.drds.binlog.parser;

import beautiful.butterfly.drds.binlog.event.EventData;
import beautiful.butterfly.drds.binlog.event.data.RowsQueryEventData;
import beautiful.butterfly.drds.binlog.utils.ByteUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RowsQueryEventDataParser implements EventDataParser
{


    @Override
    public EventData parse(ByteBuf msg, ChannelHandlerContext context, int checksumLength)
    {
        log.info("enter RowsQueryEventDataParser.parse(...)");
        int len = ByteUtils.readUnsignedInt(msg, 1);
        String queryStr = ByteUtils.readSpecifiedLengthString(msg, len);
        // 构造对象
        RowsQueryEventData eventData = new RowsQueryEventData();
        eventData.setQuery(queryStr);
        return eventData;
    }

}
